﻿package export.monster
{
	import base.*;
	
	import com.dusk.util.ResUtil;
	import com.greensock.*;
	
	import export.bullet.*;
	
	import flash.display.*;
	import flash.geom.*;
	import flash.utils.*;
	
	public class Monster1111 extends BaseMonster
	{
		
		
		public function Monster1111()
		{
			super();
			this.horizonSpeed = 11;
			this.setHp(111111);
			this.setSHp(111111);
			this.protectedParamsObject.mysee = 300;
			this.protectedParamsObject.isattback = 50;
			this.mavo.attackRange = 250;
			this.mavo.alertRange = 1000;
			this.normalAttackRate = 0.567;
			this.protectedParamsObject.def = 333;
			this.protectedParamsObject.mDef = 0.311;
			this.protectedParamsObject.exp = 0;
			this.protectedParamsObject.gxp = 0;
			this.attackBackInfoDict["hit1"] = {
				"hitMaxCount"    : 99,
				"attackBackSpeed": [6, -5],
				"attackInterval" : 24,
				"power"          : 1,
				"attackKind"     : "physics"
			};
			this.attackBackInfoDict["hit2"] = {
				"hitMaxCount"    : 99,
				"attackBackSpeed": [2, -4],
				"attackInterval" : 4,
				"power"          : 44,
				"attackKind"     : "magic",
				"addEffect"      : [{
					"name": BaseAddEffect.STUN,
					"time": gc.frameClips * 5
				}]
			};
			this.attackBackInfoDict["hit3"] = {
				"hitMaxCount"    : 99,
				"attackBackSpeed": [6, -5],
				"attackInterval" : 24,
				"power"          : 10,
				"attackKind"     : "physics",
				"addEffect"      : [{
					"name" : BaseAddEffect.POISON,
					"time" : gc.frameClips * 10,
					"power": 111
				}, {
					"name": BaseAddEffect.POISON_TIMES,
					"time": gc.frameClips * 10
				}]
			};
			this.attackBackInfoDict["hit4"] = {
				"hitMaxCount"    : 99,
				"attackBackSpeed": [6, -5],
				"attackInterval" : 4,
				"power"          : 44,
				"attackKind"     : "magic"
			};
			this.mavo.isBoss = true;
			this.mavo.monsterName = "汪汪";
			gc.gameInfo.addBossBlood(this.mavo.monsterName,this.getHp() / this.getHpMax());
			this.setAction("idle");
			this.protectedParamsObject.probability = 0.5;
			this.mavo.fallList = [{
				"name"   : "bxg",
				"bigtype": "zb"
			}];
			this.skillCD1 = [gc.frameClips * 8, gc.frameClips * 12];
			this.skillCD2 = [gc.frameClips * 8, gc.frameClips * 12];
			this.skillCD3 = [gc.frameClips * 8, gc.frameClips * 12];
		}
		
		override protected function initBBDC():void
		{
			var _loc1_:* = null;
			var _loc2_:Array = BaseBitmapDataPool.getBitmapDataArrayByName("Monster1111");
			if (_loc2_)
			{
				_loc1_ = {
					"name"  : "body",
					"source": _loc2_
				};
				bbdc = new BaseBitmapDataClip([_loc1_], 167, 129, new Point(0, 0));
				bbdc.setOffsetXY(0, 10);
				bbdc.setFrameStopCount([[5, 5, 5, 5, 5, 5, 5], [2, 2, 2, 3, 2, 4], [6, 6, 6, 6, 6, 6, 6, 6, 6, 6], [4, 4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5], [15], [6, 3, 3, 2, 13], [9, 10, 4, 4, 4, 4, 4, 4, 4, 4]]);
				bbdc.setFrameCount([7, 6, 10, 8, 7, 1, 5, 10]);
				bbdc.setEnterFrameCallBack(this.enterFrameFunc, this.exitFrameFunc);
				bbdc.setAddScriptWhenFrameOver(this.scriptFrameOverFunc);
				this.bodyContainer.addChild(bbdc);
				return;
			}
			throw new Error("Monster1111--BitmapData Error!");
		}
		
		override protected function initCollideArea():void
		{
			this.colipse = ResUtil.getNewObj("ObjectBaseSprite5") as Sprite;
			this.colipse.visible = false;
			this.addChild(this.colipse);
		}
		
		override public function setAction(param1:String):void
		{
			super.setAction(param1);
			var _loc2_:Point = this.bbdc.getCurPoint();
			switch (param1)
			{
				case "idle":
					if (_loc2_.y != 1)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(1);
					}
					this.bbdc.setState(param1);
					break;
				case "walk":
					if (_loc2_.y != 0)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(0);
					}
					this.bbdc.setState(param1);
					break;
				case "hurt":
					if (_loc2_.y != 5)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(5);
					}
					this.bbdc.setState(param1);
					break;
				case "hit1":
					if (_loc2_.y != 7)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(7);
					}
					this.bbdc.setState(param1);
					break;
				case "hit2":
					if (_loc2_.y != 3)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(3);
					}
					this.bbdc.setState(param1);
					break;
				case "hit3":
					if (_loc2_.y != 4)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(4);
					}
					this.bbdc.setState(param1);
					break;
				case "hit4":
					if (_loc2_.y != 2)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(2);
					}
					this.bbdc.setState(param1);
					break;
				case "dead":
					if (_loc2_.y != 6)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(6);
					}
					this.bbdc.setState(param1);
			}
		}
		
		override protected function scriptFrameOverFunc(param1:int):void
		{
			var _loc2_:String = this.bbdc.getState();
			switch (_loc2_)
			{
				case "walk":
					this.bbdc.setFramePointX(0);
					break;
				case "idle":
					this.bbdc.setFramePointX(0);
					break;
				case "hit1":
					this.setAction("idle");
					break;
				case "hit2":
					this.setAction("idle");
					break;
				case "hit3":
					this.setAction("idle");
					break;
				case "hit4":
					this.setAction("idle");
					break;
				case "hurt":
					this.setStatic();
					this.setAction("idle");
					break;
				case "dead":
					this.dropAura();
					this.destroy();
			}
		}
		
		override protected function enterFrameFunc(param1:Point):void
		{
			var _loc2_:String = this.bbdc.getState();
			var _loc3_:uint = this.getBBDC().getDirect();
			switch (_loc2_)
			{
				case "hit1":
					if (param1.x == 0)
					{
						if (this.bbdc.getCurFrameCount() == 9)
						{
							this.doHit1(_loc3_);
							break;
						}
						break;
					}
				case "hit2":
					if (param1.x == 0)
					{
						if (this.bbdc.getCurFrameCount() == 4)
						{
							this.doHit2(_loc3_);
							break;
						}
						break;
					}
					break;
				case "hit3":
					if (param1.x == 0)
					{
						if (this.bbdc.getCurFrameCount() == 5)
						{
							this.doHit3(_loc3_);
						}
						if (_loc3_ == 0)
						{
							this.velocity.x = -12;
							break;
						}
						this.velocity.x = 12;
						break;
					}
					break;
				case "hit4":
					if (param1.x == 0)
					{
						if (this.bbdc.getCurFrameCount() == 6)
						{
							this.doHit4(_loc3_);
							break;
						}
						break;
					}
			}
		}
		
		override protected function beforeSkill1Start():Boolean
		{
			return Boolean(this.curAttackTarget) && AUtils.GetDisBetweenTwoObj(this.curAttackTarget, this) < 200;
		}
		
		override protected function beforeSkill2Start():Boolean
		{
			return this.curAttackTarget;
		}
		
		override protected function beforeSkill3Start():Boolean
		{
			return Boolean(this.curAttackTarget) && AUtils.GetDisBetweenTwoObj(this.curAttackTarget, this) > 300;
		}
		
		override protected function releSkill1():void
		{
			this.faceToTarget();
			
			this.setInvincible(32);
			this.setAction("hit2");
			this.lastHit = "hit2";
		}
		
		override protected function releSkill2():void
		{
			this.faceToTarget();
			
			this.setInvincible(24);
			this.setAction("hit3");
			this.lastHit = "hit3";
		}
		
		override protected function releSkill3():void
		{
			this.faceToTarget();
			
			this.setInvincible(52);
			this.setAction("hit4");
			this.lastHit = "hit4";
		}
		
		override public function isCanMoveWhenAttack():Boolean
		{
			return this.curAction == "hit3";
		}
		
		override public function isAttacking():Boolean
		{
			return this.curAction == "hit1" || this.curAction == "hit2" || this.curAction == "hit3" || this.curAction == "hit4";
		}
		
		override protected function exitFrameFunc(param1:Point):void
		{
		}
		
		override protected function myIntelligence():void
		{
			if (!this.isBeAttacking())
			{
				super.myIntelligence();
			}
		}
		
		override public function destroy():void
		{
			super.destroy();
		}
		
		private function doHit1(param1:uint):void
		{
			this.setInvincible(40);
			var _loc2_:FollowTargetBullet = new FollowTargetBullet("Monster1111Bullet4");
			_loc2_.x = this.x;
			_loc2_.y = this.y;
			_loc2_.setOwner(this);
			_loc2_.setDirect(0);
			_loc2_.setAction("hit4");
			gc.gameScene.addChild(_loc2_);
			this.magicBulletArray.push(_loc2_);
		}
		
		private function doHit2(param1:uint):void
		{
			var _loc2_:FollowTargetBullet = new FollowTargetBullet("Monster1111Bullet2");
			_loc2_.x = this.x;
			_loc2_.y = this.y + 50;
			_loc2_.setOwner(this);
			_loc2_.setDirect(0);
			_loc2_.setAction("hit2");
			gc.gameScene.addChild(_loc2_);
			this.magicBulletArray.push(_loc2_);
		}
		
		private function doHit3(param1:uint):void
		{
			this.doSingleHit3(param1, 5, 0);
		}
		
		private function doSingleHit3(param1:int, param2:int, param3:int):void
		{
			var b:SpecialEffectBullet = null;
			var direct:int = param1;
			var count:int = param2;
			var index:int = param3;
			if (count > 0)
			{
				b = new SpecialEffectBullet("Monster1111Bullet3");
				if (direct == 0)
				{
					b.x = this.x - index * 15;
				}
				else
				{
					b.x = this.x + index * 15;
				}
				b.y = this.y + 70;
				b.setOwner(this);
				b.setDirect(direct);
				b.setAction("hit3");
				gc.gameScene.addChild(b);
				this.magicBulletArray.push(b);
				count = Number(count) - 1;
				index = Number(index) + 1;
				setTimeout(function (param1:Monster1111):*
				{
					if (!param1.isDead())
					{
						param1.doSingleHit3(direct, count, index);
					}
				}, 300, this);
			}
		}
		
		private function doHit4(param1:uint):void
		{
			var _loc2_:int = 0;
			var _loc3_:* = null;
			var _loc4_:FollowTargetBullet = new FollowTargetBullet("Monster1111Bullet1");
			if (param1 == 0)
			{
				_loc4_.x = this.x + 10;
			}
			else
			{
				_loc4_.x = this.x - 10;
			}
			_loc4_.y = this.y + 70;
			_loc4_.setDisable();
			_loc4_.setOwner(this);
			_loc4_.setDirect(0);
			_loc4_.setAction("idle");
			gc.gameScene.addChild(_loc4_);
			this.magicBulletArray.push(_loc4_);
			while (_loc2_ < gc.team.getHeroArray().length)
			{
				_loc3_ = gc.team.getHeroArray()[_loc2_] as BaseHero;
				if (!_loc3_.isDead())
				{
					_loc3_.addCurAddEffect([{
						"name": BaseAddEffect.EYE_FIX,
						"time": gc.frameClips * 5
					}]);
				}
				TweenMax.to(_loc3_, 2, {
					"x": this.x,
					"y": this.y
				});
				_loc2_++;
			}
		}
	}
}
